package vlms.dao;

import java.sql.*;
import vlms.exception.CartRecordCountException;

public class CartRecordCountDAO {
	public CartRecordCountDAO() {
	}

	public CartRecordCount getRecordCount(Connection con)
			throws CartRecordCountException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			stmt = con.prepareStatement("SELECT COUNT(*) FROM CART");
			rs = stmt.executeQuery();
			rs.next();
			CartRecordCount vo = new CartRecordCount();
			vo.setCount(rs.getInt(1));
			return vo;
		} catch (SQLException sqle) {
			throw new CartRecordCountException(sqle);
		} catch (Exception e) {
			throw new CartRecordCountException(e);
		}
	}

	public CartRecordCount getRecordCount(Connection con, String whereClause)
			throws CartRecordCountException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			stmt = con.prepareStatement("SELECT COUNT(*) FROM CART  "
					+ whereClause);
			rs = stmt.executeQuery();
			rs.next();
			CartRecordCount vo = new CartRecordCount();
			vo.setCount(rs.getInt(1));
			return vo;
		} catch (SQLException sqle) {
			throw new CartRecordCountException(sqle);
		} catch (Exception e) {
			throw new CartRecordCountException(e);
		}
	}
}
